package com.xac.biz.friend.ui;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.xac.R;
import com.xac.aas.model.UserInfo;
import com.xac.biz.friend.logic.FriendManager;

public class FriendActivity extends Activity {
	private ListView frientList = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.d("FriendActivity", "onCreate incoked!");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.friend);
		
		List<UserInfo> friendList = FriendManager.getInstance().retrieveFriendList();
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		int i = 0;
		for(UserInfo userInfo : friendList){
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("friendUsername", userInfo.getUsername());
	        map.put("friendUser", userInfo.getUser());
	        map.put("friendImage", R.drawable.ic_launcher);
	        list.add(map);
			i ++;
		}
		Log.d("FriendActivity", "list of map size:" + list.size());
		frientList = (ListView) findViewById(R.id.friendList);
		SimpleAdapter adapter = new SimpleAdapter(this, list,R.layout.friend_list_item,
                new String[]{"friendImage","friendUsername","friendUser"},
                new int[]{R.id.friendImage,R.id.friendUsername,R.id.friendUser});
		frientList.setAdapter(adapter);
		
		//frientList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,friendNames));
	}

}